--sample script to create a 10 mb db on the default install paths for logs and Dbs
--with a Domain user identified here as useraccount
--this script is operated by administrator on the local server, the name of the db for this script is
--Sample10mb which needs to be changed each time for a different customer



IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'Sample10mb')
	DROP DATABASE [Sample10mb]
GO

CREATE DATABASE [Sample10mb]  ON (NAME = N'Sample10mb_Data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\Sample10mb_Data.MDF' , SIZE = 10, FILEGROWTH = 10%) LOG ON (NAME = N'Sample10mb_Log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\Sample10mb_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)
 COLLATE SQL_Latin1_General_CP1_CI_AS
GO

exec sp_dboption N'Sample10mb', N'autoclose', N'false'
GO

exec sp_dboption N'Sample10mb', N'bulkcopy', N'false'
GO

exec sp_dboption N'Sample10mb', N'trunc. log', N'false'
GO

exec sp_dboption N'Sample10mb', N'torn page detection', N'true'
GO

exec sp_dboption N'Sample10mb', N'read only', N'false'
GO

exec sp_dboption N'Sample10mb', N'dbo use', N'false'
GO

exec sp_dboption N'Sample10mb', N'single', N'false'
GO

exec sp_dboption N'Sample10mb', N'autoshrink', N'false'
GO

exec sp_dboption N'Sample10mb', N'ANSI null default', N'false'
GO

exec sp_dboption N'Sample10mb', N'recursive triggers', N'false'
GO

exec sp_dboption N'Sample10mb', N'ANSI nulls', N'false'
GO

exec sp_dboption N'Sample10mb', N'concat null yields null', N'false'
GO

exec sp_dboption N'Sample10mb', N'cursor close on commit', N'false'
GO

exec sp_dboption N'Sample10mb', N'default to local cursor', N'false'
GO

exec sp_dboption N'Sample10mb', N'quoted identifier', N'false'
GO

exec sp_dboption N'Sample10mb', N'ANSI warnings', N'false'
GO

exec sp_dboption N'Sample10mb', N'auto create statistics', N'true'
GO

exec sp_dboption N'Sample10mb', N'auto update statistics', N'true'
GO

if( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 724) )
	exec sp_dboption N'Sample10mb', N'db chaining', N'false'
GO

use [Sample10mb]
GO

if not exists (select * from dbo.sysusers where name = N'BUILTIN\Administrators' and uid < 16382)
	EXEC sp_grantdbaccess N'BUILTIN\Administrators', N'BUILTIN\Administrators'
GO

if not exists (select * from dbo.sysusers where name = N'DOMAIN\useraccount' and uid < 16382)
	EXEC sp_grantdbaccess N'Domain\useraccount', N'DOMAIN\useraccount'
GO

exec sp_addrolemember N'db_owner', N'BUILTIN\Administrators'
GO

exec sp_addrolemember N'db_owner', N'DOMAIN\useraccount'
GO

